package cn.mzcode.xyzpfuwuduan.controller;

import cn.mzcode.xyzpfuwuduan.common.ServerResponse;
import cn.mzcode.xyzpfuwuduan.pojo.Company;
import cn.mzcode.xyzpfuwuduan.pojo.Position;
import cn.mzcode.xyzpfuwuduan.service.IPositionService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/position/")
public class PositionCotroller {

    @Autowired
    private IPositionService iPositionService;

    /**
     * 添加或更新职位
     * @param position
     * @return
     */
    @RequestMapping("save_Or_Update.do")
    public ServerResponse PositionSaveOrUpdate(Position position){
        return iPositionService.saveOrUpdatePosition(position);
    }

    /**
     * 搜索职位信息（如有条件按条件查询，如没有条件则列出所有职位信息）
      * @param position
     * @param pageNum
     * @param pageSize
     * @return
     */
    @RequestMapping("select.do")
    public ServerResponse<PageInfo> select(Position position , @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                           @RequestParam(value = "pageSize", defaultValue = "10") int pageSize){
        return iPositionService.selectPosition(position,pageNum,pageSize);
    }
}
